<#assign ctx=springMacroRequestContext.contextPath />
<#include "/macro/publicMacro.ftl">
<#import "/macro/pagination.ftl" as Pagination>
<#import "/macro/FormItem.ftl" as Form>

<@header title="重置密码">

</@header>

<@body>
    <h2 class="module-title">重置密码</h2>
    <#if errorPassword??>
        <div class="alert alert-primary" role="alert">
            ${errorPassword}
        </div>
    </#if>

    <form class="form-horizontal" id="userForm" action="/manager/changePassword" method="post">
        <@Form.FormItem name="oldPassword" label="旧密码">
            <input type="password" class="form-control" name="oldPassword" id="oldPassword" aria-describedby="旧密码">
        </@Form.FormItem>
        <@Form.FormItem name="newPassword" label="新密码">
            <input type="password" class="form-control" name="newPassword" id="newPassword" aria-describedby="新密码">
        </@Form.FormItem>
        <@Form.FormItem name="newPasswordTwo" label="新密码">
            <input type="password" class="form-control" name="newPasswordTwo" id="newPasswordTwo" aria-describedby="重输入新密码">
        </@Form.FormItem>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary">提交</button>
            </div>
        </div>
    </form>
</@body>

<@footer>
    <script src="${ctx}/resource/common/js/jquery.validate.min.js"></script>

    <script type="text/javascript">
        jQuery.validator.addMethod("regPassword", function(value, element) {
            return this.optional( element ) || /^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&*]+$)(?![a-zA-z\d]+$)(?![a-zA-z!@#$%^&*]+$)(?![\d!@#$%^&*]+$)[a-zA-Z\d!@#$%^&*]+$/.test( value );
        }, '密码必须包含数字、字母、特殊符号');

        $(document).ready(function () {
            $("#userForm").validate({
                rules: {
                    oldPassword: {
                        required: true,
                        rangelength: [8, 16]
                    },
                    newPassword: {
                        required: true,
                        regPassword: true,
                        rangelength: [8, 16]
                    },
                    newPasswordTwo: {
                        equalTo: "#newPassword"
                    }
                },
                messages: {
                    oldPassword: {
                        required: "旧密码不能为空",
                        rangelength: "旧密码必须在8到16个字符之间"
                    },
                    newPassword: {
                        required: "旧密码不能为空",
                        rangelength: "旧密码必须在8到16个字符之间"
                    },
                    newPasswordTwo: {
                        equalTo: "两次输入的密码必须相等"
                    }
                }
            });
        });
    </script>
</@footer>